/**
 * Created by hasee on 2017/7/18.
 */
//全部的评委
var bindPingWei = function (dom) {
    $.post($().AbsUrlParse("/web/ensadmin/findAllPingWei"), {}, function (res) {
        if (res.res.code == 40000) {
            var data = res.res.data;
            var htm = "<option value=''>请选择评委</option>";
            for (var i = 0; i < data.length; i++) {
                htm = htm + "<option value='" + data[i].userName+ "'>" + data[i].userName+ "</option>";
            }
            $(dom).html(htm);

            $(dom).multipleSelect({
                single: true,
                filter: true,
                width: '20%',
                placeholder: "请选择评委"
            });
            $(dom).change(function () {
                var name = $(this).children('option:selected').text()
                if(name=="请选择评委"){
                    $("input[name=pingweiName]").val("");
                }else{
                    $("input[name=pingweiName]").val(name);
                }

            });
        }
    });
};

//全部的未评分项目
var bindProject = function (dom) {
    $.post($().AbsUrlParse("/web/projectallocation/noScoreAll"), {}, function (res) {
        if (res.res.code == 40000) {
            var data = res.res.data;
            var htm = "<option value=''>请选择项目</option>";
            // $(dom).html(htm);
            for (var i = 0; i < data.length; i++) {
                htm = htm + "<option class='singlea' value='" + data[i].projectName+ "'>" + data[i].projectName+ "</option>";
            }
            $(dom).html(htm);
            $(dom).multipleSelect({
                single: true,
                filter: true,
                width: '20%',
                placeholder: "请选择项目"
            });

            $(dom).change(function () {
                var name = $(this).children('option:selected').text();
                if(name=="请选择项目"){
                    $("input[name=projectName]").val("");
                }else{
                    $("input[name=projectName]").val(name);
                }
            });
        }
    });
};


$(function(){
    bindPingWei("#pingwei");
    bindProject("#project");
})

bindClick("#search",function(){

    var judgesName = $("#pingwei").val();
    var projectName = $("#project").val();

    if(judgesName==null||judgesName==","){
        judgesName = "";
    }
    if(projectName==null||projectName==","){
        projectName = "";
    }


    var url = $().AbsUrlParse("/web/userproject/noScore?judgesName="+judgesName+"&projectName="+projectName);
    $("#table").bootstrapTable("refresh", {"url": url});
})


//下面是对未评分的项目进行发送短信及邮件
bindClick("#noScoreEmAndMob",function(){
    comment.showOperationTips("确定发送邮件与短信吗？",function(){
        $.post($().AbsUrlParse("/web/projectallocation/noScoreEmAndMob"),{},function(data){

        });
    });
});
